<?php
/**
 * Created by JetBrains PhpStorm.
 * User: manuel.moyano
 * Date: 17/09/13
 * Time: 10:35
 * To change this template use File | Settings | File Templates.
 */

class companies
{

    protected $table = "companies";

    public $id = 0;
    public $name;
    public $code;
    public $image;
    public $typeimage;
    public $active;

    public $create_date;
    public $create_user;
    public $update_date;
    public $update_user;
    public $profiles = array();

    function companies(){
        $this->con = new DataBase();
    }

    function open($query)
    {
        if(!is_array($query)){

            if(is_numeric($query))
                $result = $this->con->genericQuery("select * from " . $this->table . " where id = '$query'");    

            $query = $result[0];
                
        }
        if (count($query) == 0)
            return false;
        else {
            $this->id = $query['id'];
            $this->name = $query['name'];
            $this->code = $query['code'];
            $this->image = $query['image'];
            $this->typeimage = $query['typeimage'];
            $this->active = $query['active'];
            

            $this->create_date = $query['create_date'];
            $this->create_user = $query['create_user'];
            $this->update_date = $query['update_date'];
            $this->update_user = $query['update_user'];

            return true;
        }
    }
}